﻿
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Linq;

namespace Zocono.WCS.Comm
{
    public class ServiceProviderInstance
    {
        public static IServiceProvider Instance { get; set; }

        public static T GetServiceByClassNmae<T>(string serviceName)
        {
             
            var scope = Instance.CreateScope();
           
            var rv = scope.ServiceProvider.GetServices<T>().SingleOrDefault(s => s.GetType().Name == serviceName);
            return rv;
             
        }
    }

}
